package at.sysarch.bean;

import at.pimpmypipe.interfaces.Readable;
import at.sysarch.domain.TransferImage;
import at.sysarch.filter.DilateFilter;
import at.sysarch.utils.KernelHelper;
import at.sysarch.utils.LinkEvent;
import at.sysarch.utils.LinkListener;

public class Dilate extends AbstractBean<DilateFilter> implements LinkListener {

	private static final long serialVersionUID = 1L;
		
	public Dilate() {
		
		_filter = new DilateFilter(this);
	}

	@Override
	public void linkBean(LinkEvent event) {
		_filter.setInput(event.getInput());
		event.getInput().setOutput(_filter);
		_filter.run();
	}

	@Override
	public void addLinkListener(LinkListener listener) {
		listener.linkBean(new LinkEvent((Readable<TransferImage>)_filter));
	}

	@Override
	public void removeLinkListener(LinkListener listener) {		
	}
	
	public void setKernel(int size) {
		
		_filter.setKernel(KernelHelper.getKernel(size, size));
		_filter.run();
	}
	
	public int getKernel() {
		
		return _filter.getKernel().getHeight();
	}
}
